package com.zzyl.utils;

import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONObject;

public class InvokeWorkFlow {
    public static void main(String[] args) {
        String url = "http://192.168.100.188/v1/workflows/run";

        //工作流的输入 参数
        JSONObject inputs = new JSONObject();
        inputs.set("iotId", "69002fd0f1b5ec6a69c3b6b1_watch001");
        inputs.set("functionId", "HeartRate");
        inputs.set("startTime", "2025-11-04 00:00:00");
        inputs.set("endTime", "2025-11-04 23:59:59");

        JSONObject requestBody = new JSONObject();
        requestBody.set("inputs", inputs);
        requestBody.set("user", "abc");
        requestBody.set("response_mode", "blocking");


        String body = HttpRequest.post(url)
            .header("Authorization", "Bearer app-AjuHiCjCtyXzBc2BnJ0bP1tz")
            .header("Content-Type", "application/json")
            .body(requestBody.toString())
            .execute().body();

        System.out.println("body = " + body);
    }
}